#!/usr/bin/env python
# coding: utf-8

# In[37]:


import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn.model_selection import train_test_split


# In[38]:


from sklearn.linear_model.logistic import LogisticRegression


# In[39]:


x=np.linspace(0,30,20)
y=x+3*np.random.randn(20)
X=x.reshape(-1,1)
Y=y.reshape(-1,1)


# In[40]:


X_train,X_test,Y_train,Y_test=train_test_split(X,Y)#训练数据
model=LogisticRegression()     #初始化模型
model.fit(X_train,Y_train)      #训练模型  
model.predict(X_test)          #预测逻辑回归分类结果
model.predict_proba(X_test) #预测0和1的概率


# In[46]:


from sklearn.metrics import accuracy_score  #引入计算正确值的包


# In[ ]:


accuracy_score(model.predict(X_test),Y_test)   #计算逻辑回归得到的正确率

